<template>
  <div class="like">
    <Card>
      猜你喜欢
    </Card>

    <ul>
      <li v-for="like,index of likeList" :key="index" @click="handleClick(like.id)">
        <div>
          <img v-lazy="this.baseUrl + like.img_url"/>
        </div>
        <span class="name">{{ like.name }}</span>
        <span class="price">￥{{ like.price }}</span>
      </li>
    </ul>
  </div>
</template>

<script setup>
import Card from '@/components/home/Card'
import { useRouter } from 'vue-router'

const router = useRouter()

const props = defineProps(['likeList'])

const handleClick = id => {
  router.push({
    path: 'detail',
    query: {
      id
    }
  })
}
</script>

<style lang="less" scoped>
.like {
  background-color: #fff;
  ul {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: auto;
    justify-items: center;
    row-gap: 15px;

    li {
      width: 175px;
      height: 235px;
      display: flex;
      flex-direction: column;

      div {
        width: 175px;
        height: 175px;
        background-color: #f5f5f5;
        img {
          width: 100%;
          height: 100%;
        }
      }

      .name {
        padding: 8px 0;
        font-size: 15px;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
      .price {
        color: #b0352f;
        font-size: 17px;
      }
    }
  }
}
</style>